import os
import std/options
#import AndroidBackup
var args = commandLineParams()
proc usage() =
  echo "usage:"
  echo "  unpack:\tabe unpack\t<backup.ab> <backup.tar> [password]"
  echo "  pack:\t\tabe pack\t<backup.tar> <backup.ab> [password]"
  echo "  pack for 4.4:\tabe pack-kk\t<backup.tar> <backup.ab> [password]"
  echo "If the filename is `-`, then data is read from standard input"
  echo "or written to standard output."
  echo "Envvar ABE_PASSWD is tried when password is not given"

if len(args) < 3:
  usage()
  quit(1)
var mode = args[0]
if(mode!="pack" and mode!="unpack" and mode!="pack-kk"):
  usage()
  quit(1)

var unpack = mode == "unpack"
var backupFileName = if unpack: args[1]else: args[2]
var tarFileName = if unpack: args[2]else: args[1]
var password = ""
if len(args) > 3:
  password = args[3]
if len(password) == 0:
  password = getEnv("ABE_PASSWD")
if unpack:
  #AndroidBackup.extractAsTar(backupFileName, tarFileName, password)
  discard
else:
  var isKitKat = "pack-kk" == mode
  #AndroidBackup.packTar(tarFilename,backupFileName,password,isKitKat)